<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>视频审核</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
    <h2>审核视频</h2>
    <a href="/api/videos?status=0" class="btn btn-secondary mb-3">返回待审核列表</a>
    <a href="/api/videos?status=0" class="btn btn-secondary mb-3">返回待审核列表</a>

    <div class="card col-md-6">
        <div class="card-body">
            <h5 class="card-title" th:text="${video.title}"></h5>
            <p class="card-text">文件名：<span th:text="${video.fileName}"></span></p>
            <p class="card-text">大小：<span th:text="${@fileUtils.formatFileSize(video.fileSize)}"></span></p>
            <p class="card-text">上传时间：<span th:text="${video.uploadTime}"></span></p>
            <p class="card-text">上传者：<span th:text="${video.uploader}"></span></p>
        </div>
    </div>

    <form th:action="@{/api/videos/audit}" method="post" class="col-md-6 mt-4">
        <input type="hidden" name="id" th:value="${video.id}">
        <div class="mb-3">
            <label class="form-label">审核结果</label>
            <div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="status" id="pass" value="1" checked>
                    <label class="form-check-label" for="pass">通过</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="status" id="reject" value="2">
                    <label class="form-check-label" for="reject">拒绝</label>
                </div>
            </div>
        </div>
        <div class="mb-3" id="reasonGroup" style="display: none;">
            <label for="reason" class="form-label">拒绝原因</label>
            <textarea class="form-control" id="reason" name="reason" rows="3"></textarea>
        </div>
        <button type="submit" class="btn btn-primary">提交审核</button>
    </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script>
    // 拒绝时显示原因输入框
    $(function () {
        $('input[name="status"]').change(function () {
            if ($(this).val() == 2) {
                $('#reasonGroup').show();
            } else {
                $('#reasonGroup').hide();
            }
        });
    });
</script>
</body>
</html>